var ReadFileAssistant = function() {
}

ReadFileAssistant.prototype.run = function(future) {
	var args = this.controller.args;
	if(!args.path) {
		setError(future, "parameter path must be string");
	} else {
		path.exists(args.path, function(exists) {
			if(!exists) {
				setError(future, "path does not exist");
			} else {
				var fileContent = fs.readFileSync(args.path, 'utf8');
				future.result = {
					data: fileContent
				}
			}
		});
	}
}

var WriteFileAssistant = function() {
}

WriteFileAssistant.prototype.run = function(future) {
	var args = this.controller.args;
	if(!args.path) {
		setError(future, "parameter path must be string");
	} else {
		fs.writeFile(args.path, args.data, 'utf8', function(err) {
			if(err) {
				setError(future, err);
			} else {
				setResult(future, 0);
			}
		});
	}
}
